
function edit(id){
	var url = 'edit_merchandise.html?'+id;
	var config = 'dialogWidth:240px;dialogHeight:260px;scroll:no;status:no;';
	window.showModalDialog(url,'',config);
//	window.open(url,'',config);
	selectMerchandise();
};
function selectMerchandise(){
	var merchandise_name = escape(escape(document.getElementById('merchandise_name').value));
	var parent_type = escape(escape(document.getElementById('parent_type').value));
	var merchandise_type = escape(escape(document.getElementById('merchandise_type').value));
	
	var url = '/storage/manager/pages/merchandise.do?method=selectMerchandise&d=' + new Date();
	url = url + '&merchandise_name=' + merchandise_name;
	url = url + '&parent_type=' + parent_type;
	url = url + '&merchandise_type=' + merchandise_type;
	
	$.getJSON(url, {}, function(data){
		$('#merchandise_list').html('');
		
		var _max = get_max_line(470,25);
		for(var i=0;i<data.length;i++){
//       5 <th class="list" width="45">数量</th>
//       7 <th class="list" width="90">预警数量</th>
			var style_border = 0-(0-i-1)==data.length&&data.length>=_max?'border-bottom:0;':'';
			var color = '';
			if(data[i][7]>data[i][5]){
				color = 'color:#00CC00;';
			}else if(data[i][12]<data[i][5]){
				color = 'color:red;';
			}
			var merchandiseList = '';
			merchandiseList = merchandiseList + '<tr style="height:25px;" onmouseover="cbgcolor(this,0)" onmouseout="cbgcolor(this,1)">';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="100" >'+data[i][1]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="" >'+data[i][2]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="90" >'+data[i][3]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="150" >'+data[i][4]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="45" >'+data[i][5]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="45" >'+data[i][6]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="90" >'+data[i][7]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="90" >'+data[i][12]+'</td>';
			merchandiseList = merchandiseList + '  <td class="list" style="'+style_border+color+'" width="50" ><a href="javascript:void(0)" onclick="edit('+data[i][0]+')">编辑</a></td>';
			merchandiseList = merchandiseList + '</tr>';
			$('#merchandise_list').append(merchandiseList);
		}
		if(data.length<_max){
			add_foot();
		}
	});
};
function add_foot(){
	var foot = '';
    foot = foot + '<tr>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="100" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="90" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="150" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="45" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="45" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="90" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="90" >&nbsp;</td>';
	foot = foot + '  <td class="list" style="border-bottom:0;" width="50" >&nbsp;</td>';
	foot = foot + '</tr>';
	$('#merchandise_list').append(foot);
};